var app = getApp();

Page({
    data: {
        luntext: [ "在线报名" ],
        activeIndex: 0,
        estyle: [ "免费", "收费" ],
        activeIndex2: 0,
        free_Admission_one: "free_Admission",
        charge_one: "charge",
        free_Admission_two: "free_Admission",
        charge_two: "charge",
        ticket_input_one: !1,
        ticket_input_two: !1,
        ticket_name_one: "票券",
        ticket_name_two: "票券",
        delete_ticket: !1,
        add_ticket_one: !1,
        add_ticket_two: !1,
        num: 0,
        add: !0,
        set_up: [ {
            id: 1,
            one: !0,
            free_Admission_one: "free_Admission",
            charge_one: "charge",
            ticket_name_one: "票券1",
            free_Admission: "free_Admission",
            charge: "charge",
            ticket_fixed_two: "ticket_fixed",
            ticket_input: !1,
            bindblur: "bindblur",
            price: "",
            total: "",
            limit: "",
            ticket_price: "ticket_price",
            ticket_total: "ticket_total",
            ticket_limit: "ticket_limit",
            delete_ticket: "delete_ticket",
            to_examine: "to_examine",
            examine: !1
        }, {
            id: 2,
            one: !1,
            free_Admission_one: "free_Admission",
            charge_one: "charge",
            ticket_name_one: "票券2",
            free_Admission: "free_Admission",
            charge: "charge",
            ticket_fixed_two: "ticket_fixed",
            ticket_input: !1,
            bindblur: "bindblur",
            price: "",
            total: "",
            limit: "",
            ticket_price: "ticket_price",
            ticket_total: "ticket_total",
            ticket_limit: "ticket_limit",
            delete_ticket: "delete_ticket",
            to_examine: "to_examine",
            examine: !1
        }, {
            id: 3,
            one: !1,
            free_Admission_one: "free_Admission",
            charge_one: "charge",
            ticket_name_one: "票券3",
            free_Admission: "free_Admission",
            charge: "charge",
            ticket_fixed_two: "ticket_fixed",
            ticket_input: !1,
            bindblur: "bindblur",
            price: "",
            total: "",
            limit: "",
            ticket_price: "ticket_price",
            ticket_total: "ticket_total",
            ticket_limit: "ticket_limit",
            delete_ticket: "delete_ticket",
            to_examine: "to_examine",
            examine: !1
        } ],
        information: [],
        contact_informations: !1
    },
    onLoad: function(t) {
        var a = this;
        a.setData({
            options: t
        }), wx.hideShareMenu();
        var e = a.data.luntext[a.data.activeIndex];
        wx.setStorageSync("mode", e);
        var i = a.data.set_up, n = [];
        for (var o in i) 1 == i[o].one && n.push(i[o]);
        a.setData({
            list: n
        }), app.util.request({
            url: "entry/wxapp/GetBmInfo",
            cachetime: "0",
            success: function(t) {
                console.log(t);
                var e = t.data;
                for (var i in e) e[i].class = "none_select";
                2 < e.length && (e[0].class = "select", e[1].class = "select"), 0 == e.length && (e = [ {
                    name: "姓名",
                    class: "select"
                }, {
                    name: "电话",
                    class: "select"
                } ]), wx.setStorageSync("bminfo", e), a.setData({
                    bminfo: e
                });
            }
        });
    },
    free_Admission: function(t) {
        console.log("这是免费"), console.log(t);
        var e = this.data.set_up;
        console.log(e);
        var i = t.currentTarget.dataset.id;
        for (var a in e) i == e[a].id && (e[a].free_Admission_one = "free_Admission", e[a].charge_one = "charge");
        this.setData({
            set_up: e
        });
    },
    select_info: function(t) {
        console.log(t);
        var e = t.currentTarget.dataset.index, i = this.data.bminfo;
        "select" == i[e].class ? i[e].class = "none_select" : i[e].class = "select", wx.setStorageSync("bminfo", i), 
        this.setData({
            bminfo: i
        });
    },
    charge: function(t) {
        console.log("这是收费"), console.log(t);
        var e = this.data.set_up, i = t.currentTarget.dataset.id;
        for (var a in e) i == e[a].id && (e[a].free_Admission_one = "charge", e[a].charge_one = "free_Admission");
        var n = [];
        for (var o in e) 1 == e[o].one && n.push(e[o]);
        this.setData({
            set_up: e,
            list: n
        });
    },
    ticket_fixed: function(t) {
        var e = this.data.set_up, i = t.currentTarget.dataset.id;
        for (var a in e) i == e[a].id && (e[a].ticket_input = !0);
        var n = [];
        for (var o in e) 1 == e[o].one && n.push(e[o]);
        this.setData({
            set_up: e,
            list: n
        });
    },
    ticket_price: function(t) {
        var e = this.data.set_up, i = t.currentTarget.dataset.id;
        for (var a in e) i == e[a].id && (e[a].price = t.detail.value);
        var n = [];
        for (var o in e) 1 == e[o].one && n.push(e[o]);
        this.setData({
            set_up: e,
            list: n
        });
    },
    ticket_total: function(t) {
        var e = this.data.set_up, i = t.currentTarget.dataset.id;
        for (var a in e) i == e[a].id && (e[a].total = t.detail.value);
        var n = [];
        for (var o in e) 1 == e[o].one && n.push(e[o]);
        this.setData({
            set_up: e,
            list: n
        });
    },
    ticket_limit: function(t) {
        var e = this.data.set_up, i = t.currentTarget.dataset.id;
        for (var a in e) i == e[a].id && (e[a].limit = t.detail.value);
        var n = [];
        for (var o in e) 1 == e[o].one && n.push(e[o]);
        this.setData({
            set_up: e,
            list: n
        });
    },
    bindblur: function(t) {
        var e = this.data.set_up, i = t.currentTarget.dataset.id;
        if ("" != t.detail.value) for (var a in e) i == e[a].id && (e[a].ticket_name_one = t.detail.value, 
        e[a].ticket_input = !1);
        var n = [];
        for (var o in e) 1 == e[o].one && n.push(e[o]);
        this.setData({
            set_up: e,
            list: n
        });
    },
    delete_ticket: function(t) {
        this.data.set_up;
        var e = t.currentTarget.dataset.id;
        this.setData({
            delete_ticket_id: e,
            delete_ticket: !0
        });
    },
    cancel: function(t) {
        console.log(this.data.set_up), this.setData({
            delete_ticket: !1
        });
    },
    confirm: function(t) {
        var e = this.data.set_up, i = this.data.delete_ticket_id;
        for (var a in e) i == e[a].id && 1 == e[a].one && (e[a].one = !1);
        this.setData({
            set_up: e,
            delete_ticket: !1,
            add: !0
        });
    },
    add_ticket: function(t) {
        var e = this.data.set_up;
        if (0 == e[0].one) e[0].one = !0; else if (0 == e[1].one) e[1].one = !0; else if (0 == e[2].one) var i = !(e[2].one = !0);
        var a = [];
        for (var n in e) 1 == e[n].one && a.push(e[n]);
        this.setData({
            add: i,
            set_up: e,
            list: a
        });
    },
    to_examine: function(t) {
        var e = this.data.set_up;
        console.log(e), console.log(t);
        var i = t.currentTarget.dataset.id;
        for (var a in e) i == e[a].id && (e[a].examine = t.detail.value);
        var n = [];
        for (var o in e) 1 == e[o].one && n.push(e[o]);
        this.setData({
            set_up: e,
            list: n
        });
    },
    tabClick: function(t) {
        var e = t.currentTarget.id, i = this.data.luntext[e];
        this.setData({
            sliderOffset: t.currentTarget.offsetLeft,
            activeIndex: t.currentTarget.id,
            sign_up_info: i
        });
    },
    tabstyle: function(t) {
        this.setData({
            sliderOffset2: t.currentTarget.offsetLeft,
            activeIndex2: t.currentTarget.id
        });
    },
    contact_information: function(t) {
        this.data.contact_information, this.data.information;
        this.setData({
            contact_informations: !0
        });
    },
    cancel_contacts: function(t) {
        this.setData({
            contact_informations: !1
        });
    },
    add_click: function(t) {
        var e = t.currentTarget.dataset.id, i = this.data.contact_information;
        this.data.information;
        this.setData({
            information: this.data.information.concat(i[e]),
            contact_informations: !1
        });
    },
    delete_click: function(t) {
        console.log(t);
        console.log(this.data.information);
        var e = t.currentTarget.dataset.index;
        console.log("对应的index为" + e), this.setData({
            information: this.data.information.splice(e, 1)
        }), console.log(this.data.information);
    },
    next_step: function(t) {
        var e = this.data.options, i = this.data.bminfo, a = this.data.list, n = e.uplogo, o = e.title, s = e.array, c = e.classification, r = e.start_time, l = e.end_time, _ = e.address, d = e.link_tel, f = e.coordinates, u = e.sponsor, m = e.city, h = e.hx_code;
        if (console.log("用户上传的活动海报为 " + n), console.log("用户设置的活动标题为 " + o), console.log("用户选择的活动方式  线上或者线下为 " + s), 
        console.log("用户选择的活动分类为 " + c), console.log("用户选择的开始时间为 " + r), console.log("用户选择的结束时间为 " + l), 
        console.log("用户选择的活动地址为 " + _), console.log("用户所选择的地址经纬度为 " + f), console.log("用户输入的活动联系方式为 " + d), 
        console.log("主办方名字为 " + u), console.log("用户选择的城市为 " + m), null == i || "" == i) ; else {
            var p = [];
            for (var g in i) "select" == i[g].class && p.push(i[g]);
            i = [];
            p.map(function(t) {
                var e;
                e = t.id, i.push(e);
            }), p = i.join(","), console.log(p);
        }
        if (null == a || "" == a) ; else {
            var v = [];
            a.map(function(t) {
                var e = {};
                e.type = t.free_Admission_one, e.tk_name = t.ticket_name_one, "" == t.price && (t.price = 0), 
                e.money = t.price, e.total_num = t.total, e.limit_num = t.limit, e.bm_check = t.examine, 
                v.push(e);
            });
            var k = [];
            a.map(function(t) {
                var e;
                e = t.price, k.push(e);
            }), console.log(k);
            var x = Math.min.apply(null, k);
        }
        for (var b in v) "free_Admission" == v[b].type ? v[b].type = 1 : v[b].type = 2, 
        0 == v[b].bm_check ? v[b].bm_check = 2 : v[b].bm_check = 1;
        var A = "";
        if ("" == i || null == i) A = "请选择报名信息"; else if ("" == a || null == a) A = "请设置票券"; else if (0 < v.length) for (var D in v) 1 == v[D].type ? (v[D].money = 0, 
        "" == v[D].total_num ? A = "请设置票券总数" : "" == v[D].limit_num && (A = "请设置票券限购数量")) : "" == v[D].money ? A = "请设置票券价格" : "" == v[D].total_num ? A = "请设置票券总数" : "" == v[D].limit_num && (A = "请设置票券限购数量");
        "" != A ? wx.showModal({
            title: "温馨提示",
            content: A
        }) : (console.log("获取到的票券信息为"), console.log(v), console.log("获取到的报名信息为"), console.log(p), 
        wx.setStorageSync("actype", v), wx.navigateTo({
            url: "fabuinfo?uplogo=" + n + "&title=" + o + "&array=" + s + "&classification=" + c + "&start_time=" + r + "&end_time=" + l + "&bminfo=" + i + "&actype=" + v + "&address=" + _ + "&link_tel=" + d + "&coordinates=" + f + "&link_tel=" + d + "&sponsor=" + u + "&city=" + m + "&bminfo=" + i + "&samll_price=" + x + "&hx_code=" + h
        }));
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {
        this.setData({
            num: 0
        });
    },
    onPullDownRefresh: function() {},
    onReachBottom: function() {}
});